package IO流.课后作业.M4;

import java.io.Serializable;
import java.sql.Savepoint;

public class Staff implements Serializable {
    private String name;
    private int age;
    private double salary;

    public Staff() {
    }

    public Staff(String name, int age, double salary) {
        this.name = name;
        this.setAge(age);
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age < 0) {
            this.age = 18;
        }
        this.age = age;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "员工信息：\n" +
                "姓名：" + name + "\n年龄：" + age + "\n工资：" + salary+"\n";
    }
}
